Quant Exam  >  Quant Questions  >  main(){void swap();int x = 45, y = 15;swap(&a... Start Learning for Free
main(){
void swap();
int x = 45, y = 15;
swap(&x,&y);
printf(“x = %d y=%d”x,y);
}
void swap(int *a, int *b){
*a^=*b, *b^=*a, *a^ = *b;
Q. What is the output?
  • a)
    x = 15, y =45 
  • b)
    x =15, y =15 
  • c)
    x =45 ,y =15 
  • d)
    x =45 y = 45
Correct answer is option 'A'. Can you explain this answer?
Most Upvoted Answer
main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(&ldqu...
There seems to be a syntax error in your code. The opening parenthesis after the function name "swap" is not closed. Here is the corrected code:

```c++
#include

void swap(int&, int&);

int main() {
int x = 45, y = 15;
swap(x, y);
std::cout < "after="" swapping:="" x=" << x << " ,="" y=" << y << std::endl;
return 0;
}

void swap(int& a, int& b) {
int temp = a;
a = b;
b = temp;
}
```

this code defines a function called `swap` that takes two integer references as arguments and swaps their values. in the `main` function, two variables `x` and `y` are initialized with the values 45 and 15 respectively. then, the `swap` function is called to swap the values of `x` and `y`. finally, the swapped values are printed to the console. " after="" swapping:="" x=" << x << " ,="" y="" />
Explore Courses for Quant exam
main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer?
Question Description
main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer? for Quant 2025 is part of Quant preparation. The Question and answers have been prepared according to the Quant exam syllabus. Information about main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer? covers all topics & solutions for Quant 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer?.
Solutions for main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer? in English & in Hindi are available as part of our courses for Quant. Download more important topics, notes, lectures and mock test series for Quant Exam by signing up for free.
Here you can find the meaning of main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer?, a detailed solution for main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer? has been provided alongside types of main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice main(){void swap();int x = 45, y = 15;swap(&x,&y);printf(“x = %d y=%d”x,y);}void swap(int *a, int *b){*a^=*b, *b^=*a, *a^ = *b;Q.What is the output?a)x = 15, y =45b)x =15, y =15c)x =45 ,y =15d)x =45 y = 45Correct answer is option 'A'. Can you explain this answer? tests, examples and also practice Quant tests.
Explore Courses for Quant exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev